clear all
load("WB_Placebo_Pvalues.mat")
varall = WB_Placebo_Pvalues;

%Loading data, starting 1989, so we have p-values from 1990 onwards
synthetic_average = varall(:, 1); %Synthetic control's average
actual_chile = varall(:, 2); %Synthetic Chile

difference = actual_chile - synthetic_average;

n_years = length(difference);
p_values2 = zeros(1, n_years);

for year = 1:n_years
    % Select data for the current year
    data_year = difference(1:year);
    
    % Perform a one-sample t-test to compare the data to zero
    [~, p_values2(year)] = ttest(data_year);

    % Check if the p-value is less than your chosen significance level (e.g., 0.05)
    significance_level = 0.10; % 90% CI
    if p_values2(year) < significance_level
        fprintf('Year %d: The difference is statistically significantly different from zero (reject null hypothesis).\n', year);
    else
        fprintf('Year %d: The difference is not statistically significantly different from zero (fail to reject null hypothesis).\n', year);
    end
end

% Define the name of the Excel file
%excel_filename = 'p_values_WB.xlsx';

% Specify the matrix to be saved
%data_to_save = p_values2;

% Write the matrix to the Excel file
%xlswrite(excel_filename, data_to_save);


